package com.idrem.common;

import java.text.SimpleDateFormat;
import java.util.Date;

import android.app.PendingIntent;
import android.app.PendingIntent.CanceledException;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.net.Uri;
import android.provider.Settings;
import android.provider.Settings.Secure;
import android.widget.Toast;
import com.idrem.views.home.HomeAct;

public class MySharedPreferences {
	private static MySharedPreferences instance;
	private SharedPreferences myPreferences;
	private SharedPreferences sharedPreferences;

	private MySharedPreferences() {
	}

	private MySharedPreferences(Context paramContext) {
		this.myPreferences = paramContext.getSharedPreferences("myPreferences",
				0);
		this.sharedPreferences = paramContext
				.getSharedPreferences("Version", 0);
		if (Settings.Secure.isLocationProviderEnabled(
				paramContext.getContentResolver(), "gps"))
			return;
		toggleGPS(paramContext);
	}

	public static MySharedPreferences getInstance(Context paramContext) {
		if (instance == null)
			instance = new MySharedPreferences(paramContext);
		return instance;
	}

	public String get(String paramString) {
		return this.myPreferences.getString(paramString, "");
	}

	public String getAccountType() {
		return this.myPreferences.getString("accountType", "");
	}

	public String getCustArea() {
		return this.myPreferences.getString("custArea", "");
	}

	public String getCustClass2() {
		return this.myPreferences.getString("custClass2", "");
	}

	public String getCustCode() {
		return this.myPreferences.getString("custCode", "");
	}

	public String getCustName() {
		return this.myPreferences.getString("custName", "");
	}

	public String getCustTag() {
		return this.myPreferences.getString("custTag", "");
	}

	public String getCustType() {
		return this.myPreferences.getString("custType", "");
	}

	public String getCustVisitId() {
		return this.myPreferences.getString("custVisitId", "");
	}

	public String getCustXX() {
		return this.myPreferences.getString("custXX", "");
	}

	public String getCustYY() {
		return this.myPreferences.getString("custYY", "");
	}

	public String getDmsId() {
		return this.myPreferences.getString("dmsId", "");
	}

	public String getDmsName() {
		return this.myPreferences.getString("dmsName", "");
	}

	public String getDmsRegion() {
		return this.myPreferences.getString("dmsRegion", "");
	}

	public String getDsrCode() {
		return this.myPreferences.getString("dsrCode", "");
	}

	public String getDsrName() {
		return this.myPreferences.getString("dsrName", "");
	}

	public String getDsrPassword() {
		return this.myPreferences.getString("dsrPassword", "");
	}

	public String getDsrStorage() {
		return this.myPreferences.getString("dsrStorage", "");
	}

	public String getDsrType() {
		return this.myPreferences.getString("dsrType", "");
	}

	public SharedPreferences getSharedPreferences(Context paramContext) {
		if (Integer.parseInt(Common.getNowDateStr2()) > Integer
				.parseInt(this.sharedPreferences.getString("todayDate", "-1"))) {
			Toast.makeText(paramContext, "强制退出", 1).show();
			if (paramContext != null) {
				Intent localIntent = new Intent(paramContext, HomeAct.class);
				localIntent.setFlags(67108864);
				paramContext.startActivity(localIntent);
			}
		}
		return this.sharedPreferences;
	}

	public boolean isGPSEnable(Context paramContext) {
		String str = Settings.Secure
				.getString(paramContext.getContentResolver(),
						"location_providers_allowed");
		boolean bool = str.contains("gps");
		return bool;
	}

	public void set(String paramString1, String paramString2) {
		this.myPreferences.edit().putString(paramString1, paramString2)
				.commit();
	}

	public void setAccountType(String paramString) {
		this.myPreferences.edit().putString("accountType", paramString)
				.commit();
	}

	public void setCustArea(String paramString) {
		this.myPreferences.edit().putString("custArea", paramString).commit();
	}

	public void setCustClass2(String paramString) {
		this.myPreferences.edit().putString("custClass2", paramString).commit();
	}

	public void setCustCode(String paramString) {
		this.myPreferences.edit().putString("custCode", paramString).commit();
	}

	public void setCustName(String paramString) {
		this.myPreferences.edit().putString("custName", paramString).commit();
	}

	public void setCustTag(String paramString) {
		this.myPreferences.edit().putString("custTag", paramString).commit();
	}

	public void setCustType(String paramString) {
		this.myPreferences.edit().putString("custType", paramString).commit();
	}

	public void setCustVisitId(String paramString) {
		this.myPreferences.edit().putString("custVisitId", paramString)
				.commit();
	}

	public void setCustXX(String paramString) {
		this.myPreferences.edit().putString("custXX", paramString).commit();
	}

	public void setCustYY(String paramString) {
		this.myPreferences.edit().putString("custYY", paramString).commit();
	}

	public void setDmsId(String paramString) {
		this.myPreferences.edit().putString("dmsId", paramString).commit();
	}

	public void setDmsName(String paramString) {
		this.myPreferences.edit().putString("dmsName", paramString).commit();
	}

	public void setDmsRegion(String paramString) {
		this.myPreferences.edit().putString("dmsRegion", paramString).commit();
	}

	public void setDsrCode(String paramString) {
		this.myPreferences.edit().putString("dsrCode", paramString).commit();
	}

	public void setDsrName(String paramString) {
		this.myPreferences.edit().putString("dsrName", paramString).commit();
	}

	public void setDsrPassword(String paramString) {
		this.myPreferences.edit().putString("dsrPassword", paramString)
				.commit();
	}

	public void setDsrStorage(String paramString) {
		this.myPreferences.edit().putString("dsrStorage", paramString).commit();
	}

	public void setDsrType(String paramString) {
		this.myPreferences.edit().putString("dsrType", paramString).commit();
	}

	public void setTodayDate(String paramString) {
		this.sharedPreferences.edit().putString("todayDate", paramString)
				.commit();
	}

	public void toggleGPS(Context paramContext) {
		Intent localIntent = new Intent();
		localIntent.setClassName("com.android.settings",
				"com.android.settings.widget.SettingsAppWidgetProvider");
		localIntent.addCategory("android.intent.category.ALTERNATIVE");
		localIntent.setData(Uri.parse("custom:3"));
		if (paramContext != null)
			;
		try {
			PendingIntent.getBroadcast(paramContext, 0, localIntent, 0).send();
			return;
		} catch (PendingIntent.CanceledException localCanceledException) {
			localCanceledException.printStackTrace();
		}
	}
}